From: Keir Fraser Date: Fri, 4 Dec 2009 07:10:22 +0000 (+0000) Subject: libxenlight: Destroy device model only for domains that have it X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12960 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=69535954d185ebb8a6c8cf93f8912c3e86787c8a;p=xen.git libxenlight: Destroy device model only for domains that have it Destroy device model only for domains that have it. Signed-off-by: Andres Lagar-Cavilla --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 54e7b72f41..0f53dda012 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -489,7 +489,16 @@ int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force) char *dom_path, *uuid_str; char vm_path[UUID_LEN_STR + 5], vss_path[UUID_LEN_STR + 6], xapi_path[20]; xen_uuid_t *uuid; - int rc; + int rc, dm_present; + + if (is_hvm(ctx, domid)) { + dm_present = 1; + } else { + char *pid; + pid = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "/local/domain/%d/image/device-model-pid", domid)); + dm_present = (pid != NULL); + libxl_free(ctx, pid); + } dom_path = libxl_xs_get_dompath(ctx, domid); if (!dom_path) @@ -501,16 +510,20 @@ int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force) } if (libxl_device_pci_shutdown(ctx, domid) < 0) XL_LOG(ctx, XL_LOG_ERROR, "pci shutdown failed for domid %d", domid); - xs_write(ctx->xsh, XBT_NULL, - libxl_sprintf(ctx, "/local/domain/0/device-model/%d/command", domid), - "shutdown", strlen("shutdown")); + if (dm_present) { + xs_write(ctx->xsh, XBT_NULL, + libxl_sprintf(ctx, "/local/domain/0/device-model/%d/command", domid), + "shutdown", strlen("shutdown")); + } rc = xc_domain_pause(ctx->xch, domid); if (rc < 0) { XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc, "xc_domain_pause failed for %d", domid); return -1; } - if (libxl_destroy_device_model(ctx, domid) < 0) - XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_device_model failed for %d", domid); + if (dm_present) { + if (libxl_destroy_device_model(ctx, domid) < 0) + XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_device_model failed for %d", domid); + } if (libxl_devices_destroy(ctx, domid, force) < 0) XL_LOG(ctx, XL_LOG_ERROR, "libxl_destroy_devices failed for %d", domid); if (!xs_rm(ctx->xsh, XBT_NULL, dom_path))